#include "StringInputBox.h"

StringInputBox::StringInputBox(const char aPosition, const string &aName, const string &anInput) {
	this->theYPosition = aPosition;
	this->theName = aName;
	this->theString = anInput;
}

StringInputBox::~StringInputBox() {
}

void StringInputBox::run(Frame &aFrame, Event &anEvent) {
    if(this->theYPosition == anEvent.getY()) {
		if(anEvent.getX() >= Common::MIN_STRING_SIZE && anEvent.getX() <= Common::MAX_STRING_SIZE) {
			this->theString.at( (anEvent.getX()-Common::MIN_STRING_SIZE) ) = anEvent.getKey();
		}
    }
}

string StringInputBox::toString() {
	return this->theName + (this->theString);
}
